package IO第一天;

import java.io.File;

public class 递归删除文件夹 {
    public static void main(String[] args) {
        File file = new File("C:\\Users\\峰大帝\\Desktop\\新建文件夹2");
        deleteDir(file);
    }

    private static void deleteDir(File file) {
        File[] files = file.listFiles();
        if (files.length != 0) {
            for (File f : files) {
                if (f.isFile()) {
                    f.delete();
                } else if (f.isDirectory()) {
                    deleteDir(f);
                }
            }
        }
        file.delete();
    }


}
